package com.example.houselease.controller;

import com.example.houselease.pojo.vo.PermissionTemplateListVO;
import com.example.houselease.service.IPermissionService;
import com.example.houselease.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 权限 controller
 * @author sf
 * @version 0.0.1
 * */
@RestController
@Slf4j
@RequestMapping("/permissions")
public class PermissionController {

    @Autowired
    private IPermissionService permissionService;

    @GetMapping("/list")
    @PreAuthorize("hasAnyAuthority('house/permission/read')")
    JsonResult<List<PermissionTemplateListVO>> list(){
        return JsonResult.ok(permissionService.list());
    }
}
